<#import "/home/masterTemplate.ftl" as layout />
<#include "/macros/utils.ftl" />
<#import "../macros/spring.ftl" as spring />
<#include "./includes/utils.ftl" />

<#----><#include "/dumps/dump-util.ftl" />

<#assign scriptsObj>
	<#if isMobile()>

	<#else>
		require(["../../js/modules/form", "../../js/exams/exams"], function() {
	</#if>
		base.init();
		base.exams.init();
	<#if !isMobile()>
		});
	</#if>
</#assign>

<#if m_site.m_user.privileges == 1>
	<#assign index = "5"/>
<#else>
	<#assign index = "0" />
</#if>
<@layout.masterTemplate wtSection="exams" wtSubsection="" title="" bodycss="" wrappercss="bg" section="home" subsection="" pagename="" color="" sectionIdx=index> 
	
		<#if m_site.m_exam??>
			<@backHeader "Apply" "Account" "Exam#${m_site.m_exam.id}"/> 
		<#else>
			<@backHeader "Apply" "Account" "Exam"/> 
		</#if>


		<#if m_site.m_invalid_exam??>
			<@invalidAlert m_site.m_invalid_exam />
		<#else>
			<#assign exam = m_site.m_exam />
			<div class="examWrapper" data-id="${exam.id}">
				<div class="info">
					<#if m_site.remainingQuestions??>
						<#assign totalQuestion = exam.questionSize?c/> 
						<#assign currIndex = (exam.questionSize?number - m_site.remainingQuestions?number)/> 
						<p><strong>Exam number: </strong>${exam.id}</p>
						<p><strong>Assigned profile: </strong>${exam.profile.title}</p>
						<p><strong>Total questions: </strong>${totalQuestion}</p>
					</#if>
				</div>


				<div class="questionWrapper">
					<#if !m_site.m_complete??>
						<#if m_site.m_question?? && m_site.remainingQuestions??>
							<#assign question = m_site.m_question />
							<@displayQuestion question currIndex totalQuestion />
						</#if>
					<#else>
						<@getResult />
					</#if>
				</div>
			</div>
		</#if>


		<div class="modal fade" id="confirmReload" tabindex="-1" role="dialog" aria-labelledby="confirmDialog" aria-hidden="true">
		    <div class="modal-dialog">
		        <div class="modal-content">
		            <div class="modal-header">
		                <strong>Confirm Reload</strong>
		            </div>
		            <div class="modal-body">
		                If you leave, questions will be submitted as empty. Are you sure you want to proceed?
		            </div>
		            <div class="modal-footer">
		                <button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>
		                <a class="btn btn-danger btn-ok confirm-reload">confirm</a>
		            </div>
		        </div>
		    </div>
		</div>

	
	<#----><@dumper m_site "m_site" false true/>
</@layout.masterTemplate>